package com.controller.ljl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.entity.Odo;
import com.service.ljl.invoivceservice;
import com.service.ljl.odoservice;

@Controller
public class odocontroller {
	@Autowired
	private odoservice odoservice;
	@Autowired
	private invoivceservice invoivceservice;

	@PostMapping("/odo_list")
	@ResponseBody
	public Map find(@RequestParam("pagesize") int pagesize, @RequestParam("curpage") int currage) {
		return odoservice.findall(pagesize, currage);
	}

	@PostMapping("/odo_add")
	@ResponseBody
	public void add(@RequestBody Map map) {
		odoservice.addodo(map);
	}

	@PostMapping("/odo_update")
	@ResponseBody
	public void update(@RequestBody Map map) {
		odoservice.update(map);
	}

	@PostMapping("/odo_delete")
	@ResponseBody
	public void delete(@RequestParam("id") Long id) {
		odoservice.delete(id);
	}

	@PostMapping("/odo_odo")
	@ResponseBody
	public void odo(@RequestParam("id") Long id) {
		odoservice.odo(id);
	}

	@PostMapping("/odo_odos")
	@ResponseBody
	public void odos(@RequestBody JSONArray ids) {
		odoservice.odos(JSONObject.parseArray(ids.toString(), Long.class));
	}

	@PostMapping("/odo_revoke")
	@ResponseBody
	public void revoke(@RequestParam("id") Long id) {
		odoservice.revoke(id);
	}

	@PostMapping("/odo_revokes")
	@ResponseBody
	public void revokes(@RequestBody JSONArray ids) {
		odoservice.revokes(JSONObject.parseArray(ids.toString(), Long.class));
	}

	@PostMapping("/odo_invoice")
	@ResponseBody
	public void invoice(@RequestParam("id") Long id) {
		odoservice.invoice(id);
	}

	@PostMapping("/odo_tuihuo")
	@ResponseBody
	public void tuihuo(@RequestParam("id") Long id) {
		odoservice.tuihuo(id);
	}

	@PostMapping("/odo_invoices")
	@ResponseBody
	public void invoices(@RequestBody JSONArray ids) {
		odoservice.invoices(JSONObject.parseArray(ids.toString(), Long.class));
	}

	@PostMapping("/in_update")
	@ResponseBody
	public void invoiceupdate(@RequestBody Map map) {
		invoivceservice.update(map);
	}

	@PostMapping("/odo_findone")
	@ResponseBody
	public List<Odo> findonebyid(@RequestParam("id") Long id) {
		return odoservice.findone(id);
	}

}
